<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function getData() {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve({code: 200, data: {desc: 'Hello world!'}})
            }, 2000)


            // setTimeout(() => {
            //     reject({code: 400, data: {desc: 'Error!'}})
            // }, 4000)
        })
    }

    getData().then(res => {
        console.log(res);
    }).catch(err => {
        console.log(err);
    })
</script>
</body>
</html>
